// Thread.h: interface for the Thread class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_THREAD_H__7CEF08F9_22A5_4ABE_BE21_BE3504B96FFF__INCLUDED_)
#define AFX_THREAD_H__7CEF08F9_22A5_4ABE_BE21_BE3504B96FFF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class Thread
{
public:
	Thread();
	virtual ~Thread();

	// Thread Management
	bool CreateThread(DWORD dwCreateFlags = 0, UINT nStackSize = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
	bool Wait(); // Wait for thread to end
	bool Kill(); // Terminate a thread
	DWORD SuspendThread(); // Suspend the thread
	DWORD ResumeThread(); // Resume a suspended thread
	bool IsActive(); // Check for activity

	// Override these functions in the derived class
	virtual bool InitInstance() {return true;}
	virtual bool ExitInstance() {return true;}
	virtual int Run() {return 0;}

protected:
	static DWORD CALLBACK _ThreadFunc(LPVOID pvThread);

protected:
	HANDLE m_hThread;   // Thread handle
	DWORD m_dwThreadId; // Thread Id
	bool m_bActive;     // Activity indicator
};

#endif // !defined(AFX_THREAD_H__7CEF08F9_22A5_4ABE_BE21_BE3504B96FFF__INCLUDED_)
